package com.gitlab.lucky.eleme.service;

import com.gitlab.lucky.common.dao.mapper.IntegralConversionMapper;
import com.gitlab.lucky.common.dao.model.IntegralConversion;
import com.gitlab.lucky.common.dao.model.LuckyRecord;
import com.gitlab.lucky.common.enums.Constant;
import com.gitlab.lucky.common.service.ServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class IntegralConversionService extends ServiceImpl<IntegralConversionMapper, IntegralConversion> {

    @Autowired
    private IntegralConversionMapper integralConversionMapper;

    public static final Logger LOGGER = LoggerFactory.getLogger(IntegralConversionService.class);

    public IntegralConversion selectByRandomCode(String randomCode) {
        Example example = new Example(IntegralConversion.class);
        example.createCriteria()
                .andEqualTo("randomCode",randomCode)
                .andEqualTo("isReset",Constant.FALSE);
        List<IntegralConversion> integralConversions = this.selectByExample(example);
        if(integralConversions.size()==0){
            return null;
        }
        return integralConversions.get(0);
    }

}
